import java.io.*;
import java.util.*;
/**
 * DistortLines is like Distort but it works at line level. For info, read the comments on Distort.
 */
public class DistortLines {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(args[0]), "UTF-8"));
		LinkedList lines = new LinkedList();
		String line;
		while((line=reader.readLine())!=null) {
			if(line.isEmpty())
				continue;
			lines.add(line);
		}
		reader.close();
		for(int a=0; a<lines.size(); a++) {
			int b = (int)(Math.random() * lines.size());
			
			line = (String)lines.get(a);
			lines.set(a, lines.get(b));
			lines.set(b, line);
		}
		
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(args[1]), "UTF-8"));
		for(Iterator lnIt = lines.iterator(); lnIt.hasNext();) {
			line = (String)lnIt.next();
			writer.write(line, 0, line.length());
			writer.newLine();
			writer.newLine();
		}
		writer.close();
	}

}